<template>
  <div id="app">
    <!-- <table class="tb">
      <tr>
        <th>编号</th>
        <th>品牌名称</th>
        <th>创立时间</th>
        <th>操作</th>
      </tr>
      <tr v-for="(obj, index) in list" :key="obj.id">
        <td>{{ obj.id }}</td>
        <td>{{ obj.name }}</td>
        <td>{{ obj.time }}</td>
        <td>
          <button @click="del(index)">删除</button>
        </td>
      </tr>
      <tr>
        <td v-if="!list.length" colspan="4">没有数据咯~</td>
      </tr>
    </table> -->
    <Table :columns="columns" :data="list">
        <template slot-scope="{ index }"  slot="del">
        <Button type="error" size="small" @click="del(index)">
        删除</Button>
        </template>
    </Table>
  </div>
</template>

<script>
export default {
  data() {
    return {
        columns:[
           {
               title:'编号',
               key:'id'
           },{
               title:'品牌名称',
               key:'name'
           },{
                title:'创建时间',
               key:'time'
           },{
               title:'操作',
               width:'80',
               slot:'del',
               key:'del'
           }
        ],
      list: [
        { id: 101, name: '奔驰', time: '2020-08-01' },
        { id: 201, name: '宝马', time: '2020-08-02' },
        { id: 131, name: '奥迪', time: '2020-08-03' }
      ]
    }
  },
  methods: {
    del(e) {
        console.log(e);
      this.list.splice(e, 1)
    }
  }
}
</script>

<style scoped>
#app {
  width: 600px;
  margin: 10px auto;
}

.tb {
  border-collapse: collapse;
  width: 100%;
}

.tb th {
  background-color: #0094ff;
  color: white;
}

.tb td,
.tb th {
  padding: 5px;
  border: 1px solid black;
  text-align: center;
}

.add {
  padding: 5px;
  border: 1px solid black;
  margin-bottom: 10px;
}
</style>
